<template>
  <div id="app">
    <div>
      <van-tabbar route>
        <van-tabbar-item replace to="/" icon="home-o">
          主页
        </van-tabbar-item>
        <van-tabbar-item replace to="/category" icon="apps-o">
          分类
        </van-tabbar-item>
        <van-tabbar-item replace to="/cart" icon="cart-o">
          购物车
        </van-tabbar-item>

        <van-tabbar-item v-if="bol" replace to="/login" icon="contact">
          未登录
        </van-tabbar-item>
        <van-tabbar-item v-else replace to="/own" icon="contact">
          个人中心
        </van-tabbar-item>
      </van-tabbar>
    </div>

    <router-view/>
    <div id="zwh"></div>
  </div>
</template>

<script>
  export default {
    data(){
      return{
        bol:true
      }
    },
    created() {
      // 每次刷新，验证token，获取用户信息
      // 登录状态失效，跳转回主页
      if(this.$store.state.us == -1){
        this.$router.push("/")
      }
    },
    beforeUpdate(){
      if(this.$store.state.us != -1){
        this.bol=false
      }else{
        this.bol=true;
      }
    }

  };
</script>

<style>
  #app{
    /* background-color: #F6F6F6; */
  }
  #zwh{
    height: 3.125rem;
  }
</style>
